package com.ruoyi.base.controller;

import com.ruoyi.base.domain.Floor;
import com.ruoyi.base.domain.TreeNode;
import com.ruoyi.base.service.FloorService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 学校档案Controller
 *
 * @author ruoyi
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/base/floor")
@Api(tags = "楼层档案")
public class FloorController extends BaseController {
    @Autowired
    private FloorService floorService;

    /**
     * 查询学校档案列表
     */
    @GetMapping("/listAll")
    @ApiOperation("查询所有楼层列表")
    public R<List<TreeNode>> listAll(Floor query) {
        List<TreeNode> list = floorService.floorListAll(query).stream()
                .map(floor -> new TreeNode<Floor>().setId(floor.getId()).setName(floor.getFloorNoName()).setModel(floor))
                .collect(Collectors.toList());
        return R.ok(list);
    }
}
